
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>第1章、基础语法 · 王某人的学习笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="王飞翔">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-ad/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    

        
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="第2章.html" />
    
    
    <link rel="prev" href="第0章.html" />
    

    
        <link rel="shortcut icon" href='../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="bookmark" href='../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="apple-touch-icon" href='../source/images/apple-touch-icon.jpg'>
    
    
        
        <link rel="apple-touch-icon" sizes="120x120" href="../source/images/apple-touch-icon.jpg">
        
        <link rel="apple-touch-icon" sizes="180x180" href="../source/images/apple-touch-icon.jpg">
        
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"Blankj","repo":"glory","type":"star","size":"small","count":true}]};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://www.baidu.com" target="_blank" class="custom-link">作者介绍</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../linux/">
            
                <a href="../linux/">
            
                    
                    Linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../linux/第0章.html">
            
                <a href="../linux/第0章.html">
            
                    
                    第0章、计算机：辅助人脑的好工具
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../app/">
            
                <a href="../app/">
            
                    
                    软件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../app/git.html">
            
                <a href="../app/git.html">
            
                    
                    git使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../app/phpstrom.html">
            
                <a href="../app/phpstrom.html">
            
                    
                    phpstorm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../app/hexo.html">
            
                <a href="../app/hexo.html">
            
                    
                    hexo
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="./">
            
                <a href="./">
            
                    
                    Python3
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="第0章.html">
            
                <a href="第0章.html">
            
                    
                    第0章、简介和环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.2" data-path="第1章.html">
            
                <a href="第1章.html">
            
                    
                    第1章、基础语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="第2章.html">
            
                <a href="第2章.html">
            
                    
                    第2章、基本数据类型
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >第1章、基础语法</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><li><span class="title-icon "></span><a href="#python&#x8BBE;&#x7F6E;&#x7F16;&#x7801;"><b></b>Python&#x8BBE;&#x7F6E;&#x7F16;&#x7801;</a></li><li><span class="title-icon "></span><a href="#python-&#x547D;&#x540D;&#x89C4;&#x5219;"><b></b>python &#x547D;&#x540D;&#x89C4;&#x5219;</a></li><li><span class="title-icon "></span><a href="#python-&#x5173;&#x952E;&#x5B57;"><b></b>python &#x5173;&#x952E;&#x5B57;</a></li><li><span class="title-icon "></span><a href="#python-&#x6CE8;&#x91CA;"><b></b>python &#x6CE8;&#x91CA;</a></li><li><span class="title-icon "></span><a href="#&#x884C;&#x4E0E;&#x7F29;&#x8FDB;"><b></b>&#x884C;&#x4E0E;&#x7F29;&#x8FDB;</a></li><li><span class="title-icon "></span><a href="#&#x591A;&#x884C;&#x8BED;&#x53E5;"><b></b>&#x591A;&#x884C;&#x8BED;&#x53E5;</a></li><li><span class="title-icon "></span><a href="#python&#x6570;&#x636E;&#x7C7B;&#x578B;"><b></b>python&#x6570;&#x636E;&#x7C7B;&#x578B;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6570;&#x5B57;number&#x7C7B;&#x578B;"><b></b>&#x6570;&#x5B57;(Number)&#x7C7B;&#x578B;</a></li><li><span class="title-icon "></span><a href="#&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;"><b></b>&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;</a></li><li><span class="title-icon "></span><a href="#&#x7A7A;&#x884C;"><b></b>&#x7A7A;&#x884C;</a></li><li><span class="title-icon "></span><a href="#&#x7B49;&#x5F85;&#x7528;&#x6237;&#x8F93;&#x5165;"><b></b>&#x7B49;&#x5F85;&#x7528;&#x6237;&#x8F93;&#x5165;</a></li><li><span class="title-icon "></span><a href="#&#x540C;&#x4E00;&#x884C;&#x663E;&#x793A;&#x591A;&#x6761;&#x8BED;&#x53E5;"><b></b>&#x540C;&#x4E00;&#x884C;&#x663E;&#x793A;&#x591A;&#x6761;&#x8BED;&#x53E5;</a></li></ul></ul><li><span class="title-icon "></span><a href="#&#x591A;&#x4E2A;&#x8BED;&#x53E5;&#x6784;&#x6210;&#x4EE3;&#x7801;&#x7EC4;"><b></b>&#x591A;&#x4E2A;&#x8BED;&#x53E5;&#x6784;&#x6210;&#x4EE3;&#x7801;&#x7EC4;</a></li><ul><ul><li><span class="title-icon "></span><a href="#print-&#x8F93;&#x51FA;"><b></b>Print &#x8F93;&#x51FA;</a></li><li><span class="title-icon "></span><a href="#import-&#x4E0E;-fromimport"><b></b>import &#x4E0E; from...import</a></li></ul></ul><li><span class="title-icon "></span><a href="#&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;"><b></b>&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;</a></li></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h2 id="python&#x8BBE;&#x7F6E;&#x7F16;&#x7801;"><a name="python&#x8BBE;&#x7F6E;&#x7F16;&#x7801;" class="anchor-navigation-ex-anchor" href="#python&#x8BBE;&#x7F6E;&#x7F16;&#x7801;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="python&#x8BBE;&#x7F6E;&#x7F16;&#x7801;" class="plugin-anchor" href="#python&#x8BBE;&#x7F6E;&#x7F16;&#x7801;"><i class="fa fa-link" aria-hidden="true"></i></a>Python&#x8BBE;&#x7F6E;&#x7F16;&#x7801;</h2>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;Python 3 &#x6E90;&#x7801;&#x6587;&#x4EF6;&#x4EE5; UTF-8 &#x7F16;&#x7801;&#xFF0C;&#x6240;&#x6709;&#x5B57;&#x7B26;&#x4E32;&#x90FD;&#x662F; unicode &#x5B57;&#x7B26;&#x4E32;&#x3002; &#x5F53;&#x7136;&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x4E3A;&#x6E90;&#x7801;&#x6587;&#x4EF6;&#x6307;&#x5B9A;&#x4E0D;&#x540C;&#x7684;&#x7F16;&#x7801;&#xFF1A;</p>
<pre><code>#-*-coding:gbk-*-
</code></pre><h2 id="python-&#x547D;&#x540D;&#x89C4;&#x5219;"><a name="python-&#x547D;&#x540D;&#x89C4;&#x5219;" class="anchor-navigation-ex-anchor" href="#python-&#x547D;&#x540D;&#x89C4;&#x5219;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="python-&#x547D;&#x540D;&#x89C4;&#x5219;" class="plugin-anchor" href="#python-&#x547D;&#x540D;&#x89C4;&#x5219;"><i class="fa fa-link" aria-hidden="true"></i></a>python &#x547D;&#x540D;&#x89C4;&#x5219;</h2>
<ul>
<li>&#x6807;&#x8BC6;&#x7B26;&#x7B2C;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x5FC5;&#x987B;&#x662F;&#x5B57;&#x6BCD;&#x8868;&#x4E2D;&#x5B57;&#x6BCD;&#x6216;&#x4E0B;&#x5212;&#x7EBF; _ &#x3002;</li>
<li>&#x6807;&#x8BC6;&#x7B26;&#x7684;&#x5176;&#x4ED6;&#x7684;&#x90E8;&#x5206;&#x7531;&#x5B57;&#x6BCD;&#x3001;&#x6570;&#x5B57;&#x548C;&#x4E0B;&#x5212;&#x7EBF;&#x7EC4;&#x6210;&#x3002;</li>
<li>&#x6807;&#x8BC6;&#x7B26;&#x5BF9;&#x5927;&#x5C0F;&#x5199;&#x654F;&#x611F;&#x3002;</li>
<li>&#x5728; Python 3 &#x4E2D;&#xFF0C;&#x53EF;&#x4EE5;&#x7528;&#x4E2D;&#x6587;&#x4F5C;&#x4E3A;&#x53D8;&#x91CF;&#x540D;&#xFF0C;&#x975E; ASCII &#x6807;&#x8BC6;&#x7B26;&#x4E5F;&#x662F;&#x5141;&#x8BB8;&#x7684;&#x4E86;&#x3002;    </li>
</ul>
<h2 id="python-&#x5173;&#x952E;&#x5B57;"><a name="python-&#x5173;&#x952E;&#x5B57;" class="anchor-navigation-ex-anchor" href="#python-&#x5173;&#x952E;&#x5B57;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="python-&#x5173;&#x952E;&#x5B57;" class="plugin-anchor" href="#python-&#x5173;&#x952E;&#x5B57;"><i class="fa fa-link" aria-hidden="true"></i></a>python &#x5173;&#x952E;&#x5B57;</h2>
<p>python&#x4FDD;&#x7559;&#x5B57;
&#x4FDD;&#x7559;&#x5B57;&#x5373;&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x80FD;&#x628A;&#x5B83;&#x4EEC;&#x7528;&#x4F5C;&#x4EFB;&#x4F55;&#x6807;&#x8BC6;&#x7B26;&#x540D;&#x79F0;&#x3002;Python &#x7684;&#x6807;&#x51C6;&#x5E93;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A; keyword &#x6A21;&#x5757;&#xFF0C;&#x53EF;&#x4EE5;&#x8F93;&#x51FA;&#x5F53;&#x524D;&#x7248;&#x672C;&#x7684;&#x6240;&#x6709;&#x5173;&#x952E;&#x5B57;&#xFF1A;</p>
<pre><code>//&#x5F15;&#x5165;&#x5173;&#x952E;&#x5B57;&#x7C7B;&#x5E93;
import keyword 

//&#x8F93;&#x51FA;&#x7CFB;&#x7EDF;&#x5173;&#x952E;&#x5B57;
print(keyword.kwlist)

[&apos;False&apos;, &apos;None&apos;, &apos;True&apos;, &apos;and&apos;, &apos;as&apos;, &apos;assert&apos;, &apos;break&apos;, &apos;class&apos;, &apos;continue&apos;, &apos;def&apos;, &apos;del&apos;, &apos;elif&apos;, &apos;else&apos;, &apos;except&apos;, &apos;finally&apos;, &apos;for&apos;, &apos;from&apos;, &apos;global&apos;, &apos;if&apos;, &apos;import&apos;, &apos;in&apos;, &apos;is&apos;, &apos;lambda&apos;, &apos;nonlocal&apos;, &apos;not&apos;, &apos;or&apos;, &apos;pass&apos;, &apos;raise&apos;, &apos;return&apos;, &apos;try&apos;, &apos;while&apos;, &apos;with&apos;, &apos;yield&apos;]
</code></pre><h2 id="python-&#x6CE8;&#x91CA;"><a name="python-&#x6CE8;&#x91CA;" class="anchor-navigation-ex-anchor" href="#python-&#x6CE8;&#x91CA;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="python-&#x6CE8;&#x91CA;" class="plugin-anchor" href="#python-&#x6CE8;&#x91CA;"><i class="fa fa-link" aria-hidden="true"></i></a>python &#x6CE8;&#x91CA;</h2>
<ul>
<li>&#x5355;&#x884C;&#x6CE8;&#x91CA;</li>
</ul>
<p>Python&#x4E2D;&#x5355;&#x884C;&#x6CE8;&#x91CA;&#x4EE5; # &#x5F00;&#x5934;&#xFF0C;&#x5B9E;&#x4F8B;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code>#!/usr/bin/python3

# &#x7B2C;&#x4E00;&#x4E2A;&#x6CE8;&#x91CA;
print (&quot;Hello, Python!&quot;) # &#x7B2C;&#x4E8C;&#x4E2A;&#x6CE8;&#x91CA;    
</code></pre><ul>
<li>&#x591A;&#x884C;&#x6CE8;&#x91CA;</li>
</ul>
<p>&#x591A;&#x884C;&#x6CE8;&#x91CA;&#x53EF;&#x4EE5;&#x7528;&#x591A;&#x4E2A; # &#x53F7;&#xFF0C;&#x8FD8;&#x6709; &apos;&apos;&apos; &#x548C; &quot;&quot;&quot;&#xFF1A;</p>
<pre><code>1&#x3001;
# &#x591A;&#x884C;&#x6CE8;&#x91CA;1
# &#x591A;&#x884C;&#x6CE8;&#x91CA;2
# &#x591A;&#x884C;&#x6CE8;&#x91CA;3

2&#x3001;
&apos;&apos;&apos;
&#x591A;&#x884C;&#x6CE8;&#x91CA;1
&#x591A;&#x884C;&#x6CE8;&#x91CA;2
&#x591A;&#x884C;&#x6CE8;&#x91CA;3
&apos;&apos;&apos;        
3&#x3001;
&quot;&quot;&quot;
&#x591A;&#x884C;&#x6CE8;&#x91CA;1
&#x591A;&#x884C;&#x6CE8;&#x91CA;2
&#x591A;&#x884C;&#x6CE8;&#x91CA;3
&quot;&quot;&quot;
</code></pre><h2 id="&#x884C;&#x4E0E;&#x7F29;&#x8FDB;"><a name="&#x884C;&#x4E0E;&#x7F29;&#x8FDB;" class="anchor-navigation-ex-anchor" href="#&#x884C;&#x4E0E;&#x7F29;&#x8FDB;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x884C;&#x4E0E;&#x7F29;&#x8FDB;" class="plugin-anchor" href="#&#x884C;&#x4E0E;&#x7F29;&#x8FDB;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x884C;&#x4E0E;&#x7F29;&#x8FDB;</h2>
<p>python&#x6700;&#x5177;&#x7279;&#x8272;&#x7684;&#x5C31;&#x662F;&#x4F7F;&#x7528;&#x7F29;&#x8FDB;&#x6765;&#x8868;&#x793A;&#x4EE3;&#x7801;&#x5757;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x5927;&#x62EC;&#x53F7; {} &#x3002;</p>
<p>&#x7F29;&#x8FDB;&#x7684;&#x7A7A;&#x683C;&#x6570;&#x662F;&#x53EF;&#x53D8;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x540C;&#x4E00;&#x4E2A;&#x4EE3;&#x7801;&#x5757;&#xFF08;&#x5373;&#x540C;&#x4E00;&#x4E2A;&#x533A;&#x95F4;&#x5185;&#xFF09;&#x7684;&#x8BED;&#x53E5;&#x5FC5;&#x987B;&#x5305;&#x542B;&#x76F8;&#x540C;&#x7684;&#x7F29;&#x8FDB;&#x7A7A;&#x683C;&#x6570;&#x3002;&#x5B9E;&#x4F8B;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code>&#x6B63;&#x786E;&#xFF1A;
if 1+1 == 2:
    print(&apos;&#x6B63;&#x786E;&apos;)
else:
    print(&apos;&#x9519;&#x8BEF;&apos;)    

&#x6B63;&#x786E;&#xFF1A;        
if True:
    print(&apos;&#x884C;&#x7F29;&#x8FDB;&apos;)
else:
        print(&apos;&#x62A5;&#x9519;&apos;)

&#x62A5;&#x9519;&#xFF1A;
  if True:
        print(&apos;&#x884C;&#x7F29;&#x8FDB;&apos;)
    else:
            print(&apos;&#x62A5;&#x9519;&apos;)
  print(&apos;&#x8FD9;&#x6837;&#x624D;&#x4F1A;&#x62A5;&#x9519;&apos;)     

 IndentationError: unindent does not match any outer indentation level
</code></pre><h2 id="&#x591A;&#x884C;&#x8BED;&#x53E5;"><a name="&#x591A;&#x884C;&#x8BED;&#x53E5;" class="anchor-navigation-ex-anchor" href="#&#x591A;&#x884C;&#x8BED;&#x53E5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x591A;&#x884C;&#x8BED;&#x53E5;" class="plugin-anchor" href="#&#x591A;&#x884C;&#x8BED;&#x53E5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x591A;&#x884C;&#x8BED;&#x53E5;</h2>
<p>Python &#x901A;&#x5E38;&#x662F;&#x4E00;&#x884C;&#x5199;&#x5B8C;&#x4E00;&#x6761;&#x8BED;&#x53E5;&#xFF0C;&#x4F46;&#x5982;&#x679C;&#x8BED;&#x53E5;&#x5F88;&#x957F;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x53CD;&#x659C;&#x6760;()&#x6765;&#x5B9E;&#x73B0;&#x591A;&#x884C;&#x8BED;&#x53E5;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>result = 1+2+\
         3+4+\
         5
print(result)

15

str=&apos;&#x6211;&#x5728;&#x4E0A;&#x6D77;&apos;\
    &apos;&#x70B8;&#x9E21;&#xFF0C;&#x5C31;&#x95EE;&#x4F60;&apos;\
    &apos;&#x5403;&#x4E0D;&#x5403;&apos;
print(str)             

&#x6211;&#x5728;&#x4E0A;&#x6D77;&#x70B8;&#x9E21;&#xFF0C;&#x5C31;&#x95EE;&#x4F60;&#x5403;&#x4E0D;&#x5403;
</code></pre><p> &#x5728; [], {}, &#x6216; () &#x4E2D;&#x7684;&#x591A;&#x884C;&#x8BED;&#x53E5;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x53CD;&#x659C;&#x6760;()&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>str=[1,2,3,4,5]
print(str)
str2={&apos;a&apos;,&apos;b&apos;,&apos;c&apos;,&apos;d&apos;,&apos;e&apos;}
print(str2)
str3=(&apos;aa&apos;,&apos;bb&apos;,&apos;cc&apos;)
print(str3)

[1, 2, 3, 4, 5]
{&apos;e&apos;, &apos;c&apos;, &apos;a&apos;, &apos;d&apos;, &apos;b&apos;}
(&apos;aa&apos;, &apos;bb&apos;, &apos;cc&apos;)
</code></pre><h2 id="python&#x6570;&#x636E;&#x7C7B;&#x578B;"><a name="python&#x6570;&#x636E;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#python&#x6570;&#x636E;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="python&#x6570;&#x636E;&#x7C7B;&#x578B;" class="plugin-anchor" href="#python&#x6570;&#x636E;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>python&#x6570;&#x636E;&#x7C7B;&#x578B;</h2>
<h3 id="&#x6570;&#x5B57;number&#x7C7B;&#x578B;"><a name="&#x6570;&#x5B57;number&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x5B57;number&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x6570;&#x5B57;number&#x7C7B;&#x578B;" class="plugin-anchor" href="#&#x6570;&#x5B57;number&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6570;&#x5B57;(Number)&#x7C7B;&#x578B;</h3>
<p>python&#x4E2D;&#x6570;&#x5B57;&#x6709;&#x56DB;&#x79CD;&#x7C7B;&#x578B;&#xFF1A;&#x6574;&#x6570;&#x3001;&#x5E03;&#x5C14;&#x578B;&#x3001;&#x6D6E;&#x70B9;&#x6570;&#x548C;&#x590D;&#x6570;&#x3002;</p>
<ul>
<li>int (&#x6574;&#x6570;), &#x5982; 1, &#x53EA;&#x6709;&#x4E00;&#x79CD;&#x6574;&#x6570;&#x7C7B;&#x578B; int&#xFF0C;&#x8868;&#x793A;&#x4E3A;&#x957F;&#x6574;&#x578B;&#xFF0C;&#x6CA1;&#x6709; python2 &#x4E2D;&#x7684; Long&#x3002;</li>
<li>bool (&#x5E03;&#x5C14;), &#x5982; True&#x3002;</li>
<li>float (&#x6D6E;&#x70B9;&#x6570;), &#x5982; 1.23&#x3001;3E-2</li>
<li>complex (&#x590D;&#x6570;), &#x5982; 1 + 2j&#x3001; 1.1 + 2.2j</li>
</ul>
<h3 id="&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;"><a name="&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;" class="plugin-anchor" href="#&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;</h3>
<p>&#x5B57;&#x7B26;&#x4E32;(String)</p>
<p>python&#x4E2D;&#x5355;&#x5F15;&#x53F7;&#x548C;&#x53CC;&#x5F15;&#x53F7;&#x4F7F;&#x7528;&#x5B8C;&#x5168;&#x76F8;&#x540C;&#x3002;</p>
<p>&#x4F7F;&#x7528;&#x4E09;&#x5F15;&#x53F7;(&apos;&apos;&apos;&#x6216;&quot;&quot;&quot;)&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x4E00;&#x4E2A;&#x591A;&#x884C;&#x5B57;&#x7B26;&#x4E32;&#x3002;</p>
<p>&#x8F6C;&#x4E49;&#x7B26; \ </p>
<p>&#x53CD;&#x659C;&#x6760;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x8F6C;&#x4E49;&#xFF0C;&#x4F7F;&#x7528;r&#x53EF;&#x4EE5;&#x8BA9;&#x53CD;&#x659C;&#x6760;&#x4E0D;&#x53D1;&#x751F;&#x8F6C;&#x4E49;&#x3002;&#x3002; &#x5982; r&quot;this is a line with \n&quot; &#x5219;\n&#x4F1A;&#x663E;&#x793A;&#xFF0C;&#x5E76;&#x4E0D;&#x662F;&#x6362;&#x884C;&#x3002;</p>
<p>&#x6309;&#x5B57;&#x9762;&#x610F;&#x4E49;&#x7EA7;&#x8054;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x5982;&quot;this &quot; &quot;is &quot; &quot;string&quot;&#x4F1A;&#x88AB;&#x81EA;&#x52A8;&#x8F6C;&#x6362;&#x4E3A;this is string&#x3002;</p>
<p>&#x5B57;&#x7B26;&#x4E32;&#x53EF;&#x4EE5;&#x7528; + &#x8FD0;&#x7B97;&#x7B26;&#x8FDE;&#x63A5;&#x5728;&#x4E00;&#x8D77;&#xFF0C;&#x7528; * &#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x590D;&#x3002;</p>
<p>Python &#x4E2D;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x6709;&#x4E24;&#x79CD;&#x7D22;&#x5F15;&#x65B9;&#x5F0F;&#xFF0C;&#x4ECE;&#x5DE6;&#x5F80;&#x53F3;&#x4EE5; 0 &#x5F00;&#x59CB;&#xFF0C;&#x4ECE;&#x53F3;&#x5F80;&#x5DE6;&#x4EE5; -1 &#x5F00;&#x59CB;&#x3002;</p>
<p>Python&#x4E2D;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x4E0D;&#x80FD;&#x6539;&#x53D8;&#x3002;</p>
<p>Python &#x6CA1;&#x6709;&#x5355;&#x72EC;&#x7684;&#x5B57;&#x7B26;&#x7C7B;&#x578B;&#xFF0C;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x5C31;&#x662F;&#x957F;&#x5EA6;&#x4E3A; 1 &#x7684;&#x5B57;&#x7B26;&#x4E32;&#x3002;</p>
<p>&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x622A;&#x53D6;&#x7684;&#x8BED;&#x6CD5;&#x683C;&#x5F0F;&#x5982;&#x4E0B;&#xFF1A;&#x53D8;&#x91CF;[&#x5934;&#x4E0B;&#x6807;:&#x5C3E;&#x4E0B;&#x6807;:&#x6B65;&#x957F;]</p>
<pre><code>&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x5B9A;&#x4E49;&#xFF1A;

    str=&apos;&#x6D4B;&#x8BD5;&#x8F6C;&#x4E49;&#x7B26;&#x53F7;\n&apos;
    str2= r&apos;&#x6D4B;&#x8BD5;&#x4E0D;&#x8F6C;&#x4E49;&#x7B26;&#x53F7;\r&apos;
    print(str)
    print(str2)

    &#x6D4B;&#x8BD5;&#x8F6C;&#x4E49;&#x7B26;&#x53F7; 
    &#x6D4B;&#x8BD5;&#x4E0D;&#x8F6C;&#x4E49;&#x7B26;&#x53F7;\r

    str=&apos;&#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;1&apos;
    str2=&quot;&#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;2&quot;
    str3=&quot;&quot;&quot;&#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;
    &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;3-2
    &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;3-3&quot;&quot;&quot;
    str4=&apos;&apos;&apos;&#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;4-1
        &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;4-2
        &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;4-3&apos;&apos;&apos;
    print(str)
    print(str2)
    print(str3)
    print(str4)


    &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;1
    &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;2
    &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;
    &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;3-2
    &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;3-3
    &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;4-1
        &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;4-2
        &#x6D4B;&#x8BD5;&#x5B57;&#x7B26;&#x4E32;4-3

&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x622A;&#x53D6;&#xFF1A;

    str=&apos;abcdefghijk&apos;
    #&#x622A;&#x53D6;&#x5B57;&#x7B26;&#x4E32;
    print(str[0:1])#a
    print(str[-2:])#jk
    print(str[0])#a
    print(str[2:5])#cde
    print(str[0:2:1])#ab
    #&#x8FDE;&#x7EED;&#x8F93;&#x51FA;&#x5B57;&#x7B26;&#x4E32;&#x4E24;&#x6B21;
    print(str*2)#abcdefghijkabcdefghijk
    #&#x62FC;&#x63A5;
    print(str+&apos;&#x4F60;&#x597D;&apos;)#abcdefghijk&#x4F60;&#x597D;
    #&#x4F7F;&#x7528;&#x8F6C;&#x4E49;&#x53CD;&#x8F6C;&#x4E49;
    print(&apos;hello \n world&apos;)
    &apos;&apos;&apos;
        hello 
     world
    &apos;&apos;&apos;
    print(r&apos;hello \n world&apos;)    #hello \n world
</code></pre><h3 id="&#x7A7A;&#x884C;"><a name="&#x7A7A;&#x884C;" class="anchor-navigation-ex-anchor" href="#&#x7A7A;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x7A7A;&#x884C;" class="plugin-anchor" href="#&#x7A7A;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7A7A;&#x884C;</h3>
<p>   &#x51FD;&#x6570;&#x4E4B;&#x95F4;&#x6216;&#x7C7B;&#x7684;&#x65B9;&#x6CD5;&#x4E4B;&#x95F4;&#x7528;&#x7A7A;&#x884C;&#x5206;&#x9694;&#xFF0C;&#x8868;&#x793A;&#x4E00;&#x6BB5;&#x65B0;&#x7684;&#x4EE3;&#x7801;&#x7684;&#x5F00;&#x59CB;&#x3002;&#x7C7B;&#x548C;&#x51FD;&#x6570;&#x5165;&#x53E3;&#x4E4B;&#x95F4;&#x4E5F;&#x7528;&#x4E00;&#x884C;&#x7A7A;&#x884C;&#x5206;&#x9694;&#xFF0C;&#x4EE5;&#x7A81;&#x51FA;&#x51FD;&#x6570;&#x5165;&#x53E3;&#x7684;&#x5F00;&#x59CB;&#x3002;</p>
<p>   &#x7A7A;&#x884C;&#x4E0E;&#x4EE3;&#x7801;&#x7F29;&#x8FDB;&#x4E0D;&#x540C;&#xFF0C;&#x7A7A;&#x884C;&#x5E76;&#x4E0D;&#x662F;Python&#x8BED;&#x6CD5;&#x7684;&#x4E00;&#x90E8;&#x5206;&#x3002;&#x4E66;&#x5199;&#x65F6;&#x4E0D;&#x63D2;&#x5165;&#x7A7A;&#x884C;&#xFF0C;Python&#x89E3;&#x91CA;&#x5668;&#x8FD0;&#x884C;&#x4E5F;&#x4E0D;&#x4F1A;&#x51FA;&#x9519;&#x3002;&#x4F46;&#x662F;&#x7A7A;&#x884C;&#x7684;&#x4F5C;&#x7528;&#x5728;&#x4E8E;&#x5206;&#x9694;&#x4E24;&#x6BB5;&#x4E0D;&#x540C;&#x529F;&#x80FD;&#x6216;&#x542B;&#x4E49;&#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x4FBF;&#x4E8E;&#x65E5;&#x540E;&#x4EE3;&#x7801;&#x7684;&#x7EF4;&#x62A4;&#x6216;&#x91CD;&#x6784;&#x3002;</p>
<p>   &#x8BB0;&#x4F4F;&#xFF1A;&#x7A7A;&#x884C;&#x4E5F;&#x662F;&#x7A0B;&#x5E8F;&#x4EE3;&#x7801;&#x7684;&#x4E00;&#x90E8;&#x5206;&#x3002;</p>
<h3 id="&#x7B49;&#x5F85;&#x7528;&#x6237;&#x8F93;&#x5165;"><a name="&#x7B49;&#x5F85;&#x7528;&#x6237;&#x8F93;&#x5165;" class="anchor-navigation-ex-anchor" href="#&#x7B49;&#x5F85;&#x7528;&#x6237;&#x8F93;&#x5165;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x7B49;&#x5F85;&#x7528;&#x6237;&#x8F93;&#x5165;" class="plugin-anchor" href="#&#x7B49;&#x5F85;&#x7528;&#x6237;&#x8F93;&#x5165;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7B49;&#x5F85;&#x7528;&#x6237;&#x8F93;&#x5165;</h3>
<p>   &#x6267;&#x884C;&#x4E0B;&#x9762;&#x7684;&#x7A0B;&#x5E8F;&#x5728;&#x6309;&#x56DE;&#x8F66;&#x952E;&#x540E;&#x5C31;&#x4F1A;&#x7B49;&#x5F85;&#x7528;&#x6237;&#x8F93;&#x5165;&#xFF1A; </p>
<pre><code>input(&quot;\n\n&#x6309;&#x4E0B; enter &#x952E;&#x540E;&#x9000;&#x51FA;&#x3002;&quot;)   

&#x4EE5;&#x4E0A;&#x4EE3;&#x7801;&#x4E2D; &#xFF0C;&quot;\n\n&quot;&#x5728;&#x7ED3;&#x679C;&#x8F93;&#x51FA;&#x524D;&#x4F1A;&#x8F93;&#x51FA;&#x4E24;&#x4E2A;&#x65B0;&#x7684;&#x7A7A;&#x884C;&#x3002;&#x4E00;&#x65E6;&#x7528;&#x6237;&#x6309;&#x4E0B; enter &#x952E;&#x65F6;&#xFF0C;&#x7A0B;&#x5E8F;&#x5C06;&#x9000;&#x51FA;&#x3002;
</code></pre><h3 id="&#x540C;&#x4E00;&#x884C;&#x663E;&#x793A;&#x591A;&#x6761;&#x8BED;&#x53E5;"><a name="&#x540C;&#x4E00;&#x884C;&#x663E;&#x793A;&#x591A;&#x6761;&#x8BED;&#x53E5;" class="anchor-navigation-ex-anchor" href="#&#x540C;&#x4E00;&#x884C;&#x663E;&#x793A;&#x591A;&#x6761;&#x8BED;&#x53E5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x540C;&#x4E00;&#x884C;&#x663E;&#x793A;&#x591A;&#x6761;&#x8BED;&#x53E5;" class="plugin-anchor" href="#&#x540C;&#x4E00;&#x884C;&#x663E;&#x793A;&#x591A;&#x6761;&#x8BED;&#x53E5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x540C;&#x4E00;&#x884C;&#x663E;&#x793A;&#x591A;&#x6761;&#x8BED;&#x53E5;</h3>
<p>Python&#x53EF;&#x4EE5;&#x5728;&#x540C;&#x4E00;&#x884C;&#x4E2D;&#x4F7F;&#x7528;&#x591A;&#x6761;&#x8BED;&#x53E5;&#xFF0C;&#x8BED;&#x53E5;&#x4E4B;&#x95F4;&#x4F7F;&#x7528;&#x5206;&#x53F7;(;)&#x5206;&#x5272;&#xFF0C;&#x4EE5;&#x4E0B;&#x662F;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre><code>&#x5B9E;&#x4F8B;(Python 3.0+)
#!/usr/bin/python3

 import sys;x=&apos;abc&apos;;sys.stdout.write(x+&apos;bbb&apos;)
&#x4F7F;&#x7528;&#x811A;&#x672C;&#x6267;&#x884C;&#x4EE5;&#x4E0A;&#x4EE3;&#x7801;&#xFF0C;&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x4E3A;&#xFF1A;

abcbbb
</code></pre><p> &#x4F7F;&#x7528;&#x4EA4;&#x4E92;&#x5F0F;&#x547D;&#x4EE4;&#x884C;&#x6267;&#x884C;&#xFF0C;&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x4E3A;&#xFF1A;</p>
<pre><code>&gt;&gt;&gt;   import sys;x=&apos;abc&apos;;sys.stdout.write(x+&apos;bbb&apos;)
abcbbb
6
&#x6B64;&#x5904;&#x7684; 6 &#x8868;&#x793A;&#x5B57;&#x7B26;&#x6570;&#x3002;    
</code></pre><p><img src="source/images/4b2d118d.png" alt="">                    </p>
<h1 id="&#x591A;&#x4E2A;&#x8BED;&#x53E5;&#x6784;&#x6210;&#x4EE3;&#x7801;&#x7EC4;"><a name="&#x591A;&#x4E2A;&#x8BED;&#x53E5;&#x6784;&#x6210;&#x4EE3;&#x7801;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x591A;&#x4E2A;&#x8BED;&#x53E5;&#x6784;&#x6210;&#x4EE3;&#x7801;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x591A;&#x4E2A;&#x8BED;&#x53E5;&#x6784;&#x6210;&#x4EE3;&#x7801;&#x7EC4;" class="plugin-anchor" href="#&#x591A;&#x4E2A;&#x8BED;&#x53E5;&#x6784;&#x6210;&#x4EE3;&#x7801;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x591A;&#x4E2A;&#x8BED;&#x53E5;&#x6784;&#x6210;&#x4EE3;&#x7801;&#x7EC4;</h1>
<p> &#x7F29;&#x8FDB;&#x76F8;&#x540C;&#x7684;&#x4E00;&#x7EC4;&#x8BED;&#x53E5;&#x6784;&#x6210;&#x4E00;&#x4E2A;&#x4EE3;&#x7801;&#x5757;&#xFF0C;&#x6211;&#x4EEC;&#x79F0;&#x4E4B;&#x4EE3;&#x7801;&#x7EC4;&#x3002;</p>
<p> &#x50CF;if&#x3001;while&#x3001;def&#x548C;class&#x8FD9;&#x6837;&#x7684;&#x590D;&#x5408;&#x8BED;&#x53E5;&#xFF0C;&#x9996;&#x884C;&#x4EE5;&#x5173;&#x952E;&#x5B57;&#x5F00;&#x59CB;&#xFF0C;&#x4EE5;&#x5192;&#x53F7;( : )&#x7ED3;&#x675F;&#xFF0C;&#x8BE5;&#x884C;&#x4E4B;&#x540E;&#x7684;&#x4E00;&#x884C;&#x6216;&#x591A;&#x884C;&#x4EE3;&#x7801;&#x6784;&#x6210;&#x4EE3;&#x7801;&#x7EC4;&#x3002;</p>
<p> &#x6211;&#x4EEC;&#x5C06;&#x9996;&#x884C;&#x53CA;&#x540E;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x7EC4;&#x79F0;&#x4E3A;&#x4E00;&#x4E2A;&#x5B50;&#x53E5;(clause)&#x3002;</p>
<p> &#x5982;&#x4E0B;&#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre><code>str=&apos;c&apos;

if str == &apos;a&apos; :
    print(&apos;a&apos;)
elif str==&apos;b&apos;:
    print(&apos;b&apos;)
else :
    print(&apos;&#x5176;&#x4ED6;&apos;)

 &#x5176;&#x4ED6;
</code></pre><h3 id="print-&#x8F93;&#x51FA;"><a name="print-&#x8F93;&#x51FA;" class="anchor-navigation-ex-anchor" href="#print-&#x8F93;&#x51FA;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="print-&#x8F93;&#x51FA;" class="plugin-anchor" href="#print-&#x8F93;&#x51FA;"><i class="fa fa-link" aria-hidden="true"></i></a>Print &#x8F93;&#x51FA;</h3>
<p>   print &#x9ED8;&#x8BA4;&#x8F93;&#x51FA;&#x662F;&#x6362;&#x884C;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x8981;&#x5B9E;&#x73B0;&#x4E0D;&#x6362;&#x884C;&#x9700;&#x8981;&#x5728;&#x53D8;&#x91CF;&#x672B;&#x5C3E;&#x52A0;&#x4E0A; end=&quot;&quot;&#xFF1A;</p>
<pre><code>   x= &quot;a&quot;
   y = &quot;b&quot;
   # &#x6362;&#x884C;&#x8F93;&#x51FA;
   print(x)
   print(y)

   print(&apos;---------&apos;)
   # &#x4E0D;&#x6362;&#x884C;&#x8F93;&#x51FA;
   print(x, end=&quot; &quot;)
   print(y,end=&apos;&apos;)

  a
  b
  ---------
  a b
</code></pre><h3 id="import-&#x4E0E;-fromimport"><a name="import-&#x4E0E;-fromimport" class="anchor-navigation-ex-anchor" href="#import-&#x4E0E;-fromimport"><i class="fa fa-link" aria-hidden="true"></i></a><a name="import-&#x4E0E;-fromimport" class="plugin-anchor" href="#import-&#x4E0E;-fromimport"><i class="fa fa-link" aria-hidden="true"></i></a>import &#x4E0E; from...import</h3>
<p>   &#x5728; python &#x7528; import &#x6216;&#x8005; from...import &#x6765;&#x5BFC;&#x5165;&#x76F8;&#x5E94;&#x7684;&#x6A21;&#x5757;&#x3002;</p>
<p>   &#x5C06;&#x6574;&#x4E2A;&#x6A21;&#x5757;(somemodule)&#x5BFC;&#x5165;&#xFF0C;&#x683C;&#x5F0F;&#x4E3A;&#xFF1A; import somemodule</p>
<p>   &#x4ECE;&#x67D0;&#x4E2A;&#x6A21;&#x5757;&#x4E2D;&#x5BFC;&#x5165;&#x67D0;&#x4E2A;&#x51FD;&#x6570;,&#x683C;&#x5F0F;&#x4E3A;&#xFF1A; from somemodule import somefunction</p>
<p>   &#x4ECE;&#x67D0;&#x4E2A;&#x6A21;&#x5757;&#x4E2D;&#x5BFC;&#x5165;&#x591A;&#x4E2A;&#x51FD;&#x6570;,&#x683C;&#x5F0F;&#x4E3A;&#xFF1A; from somemodule import firstfunc, secondfunc, thirdfunc</p>
<p>   &#x5C06;&#x67D0;&#x4E2A;&#x6A21;&#x5757;&#x4E2D;&#x7684;&#x5168;&#x90E8;&#x51FD;&#x6570;&#x5BFC;&#x5165;&#xFF0C;&#x683C;&#x5F0F;&#x4E3A;&#xFF1A; from somemodule import *</p>
<pre><code>#&#x5BFC;&#x5165;sys&#x6A21;&#x5757;
import sys
print(&apos;==============python import mode=================&apos;)
print(&apos;&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x4E3A;&#xFF1A;&apos;)
for i in sys.argv:
    print(i)
    print(&apos;\n python &#x8DEF;&#x5F84;&#x4E3A;&apos;,sys.path)

#&#x5BFC;&#x5165;sys&#x6A21;&#x5757;&#x7684;argv path&#x6210;&#x5458;
from sys import argv,path
print(&apos;=============python from import ==========&apos;)
print(&apos;path:&apos;,path)#&#x56E0;&#x4E3A;&#x5DF2;&#x7ECF;&#x5BFC;&#x5165;path&#x6210;&#x5458;&#xFF0C;&#x6240;&#x4EE5;&#x6B64;&#x5904;&#x4E0D;&#x9700;&#x8981;&#x52A0;sys.path

==============python import mode=================
&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x4E3A;&#xFF1A;
D:/python/hello.py

 python &#x8DEF;&#x5F84;&#x4E3A; [&apos;D:\\python&apos;, &apos;D:\\python&apos;, &apos;D:\\Program Files\\JetBrains\\PyCharm 2019.3.1\\plugins\\python\\helpers\\pycharm_display&apos;, &apos;D:\\Program Files\\Python\\Python38-32\\python38.zip&apos;, &apos;D:\\Program Files\\Python\\Python38-32\\DLLs&apos;, &apos;D:\\Program Files\\Python\\Python38-32\\lib&apos;, &apos;D:\\Program Files\\Python\\Python38-32&apos;, &apos;D:\\python\\venv&apos;, &apos;D:\\python\\venv\\lib\\site-packages&apos;, &apos;D:\\python\\venv\\lib\\site-packages\\setuptools-40.8.0-py3.8.egg&apos;, &apos;D:\\python\\venv\\lib\\site-packages\\pip-19.0.3-py3.8.egg&apos;, &apos;D:\\Program Files\\JetBrains\\PyCharm 2019.3.1\\plugins\\python\\helpers\\pycharm_matplotlib_backend&apos;]
=============python from import ==========
path: [&apos;D:\\python&apos;, &apos;D:\\python&apos;, &apos;D:\\Program Files\\JetBrains\\PyCharm 2019.3.1\\plugins\\python\\helpers\\pycharm_display&apos;, &apos;D:\\Program Files\\Python\\Python38-32\\python38.zip&apos;, &apos;D:\\Program Files\\Python\\Python38-32\\DLLs&apos;, &apos;D:\\Program Files\\Python\\Python38-32\\lib&apos;, &apos;D:\\Program Files\\Python\\Python38-32&apos;, &apos;D:\\python\\venv&apos;, &apos;D:\\python\\venv\\lib\\site-packages&apos;, &apos;D:\\python\\venv\\lib\\site-packages\\setuptools-40.8.0-py3.8.egg&apos;, &apos;D:\\python\\venv\\lib\\site-packages\\pip-19.0.3-py3.8.egg&apos;, &apos;D:\\Program Files\\JetBrains\\PyCharm 2019.3.1\\plugins\\python\\helpers\\pycharm_matplotlib_backend&apos;]
</code></pre><h1 id="&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;"><a name="&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;" class="plugin-anchor" href="#&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;</h1>
<p> &#x5F88;&#x591A;&#x7A0B;&#x5E8F;&#x53EF;&#x4EE5;&#x6267;&#x884C;&#x4E00;&#x4E9B;&#x64CD;&#x4F5C;&#x6765;&#x67E5;&#x770B;&#x4E00;&#x4E9B;&#x57FA;&#x672C;&#x4FE1;&#x606F;&#xFF0C;Python&#x53EF;&#x4EE5;&#x4F7F;&#x7528;-h&#x53C2;&#x6570;&#x67E5;&#x770B;&#x5404;&#x53C2;&#x6570;&#x5E2E;&#x52A9;&#x4FE1;&#x606F;&#xFF1A;</p>
<pre><code>C:\Users\25795&gt;python -h
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
-b     : issue warnings about str(bytes_instance), str(bytearray_instance)
         and comparing bytes/bytearray with str. (-bb: issue errors)
-B     : don&apos;t write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x
-c cmd : program passed in as string (terminates option list)
-d     : debug output from parser; also PYTHONDEBUG=x
-E     : ignore PYTHON* environment variables (such as PYTHONPATH)
-h     : print this help message and exit (also --help)
-i     : inspect interactively after running script; forces a prompt even
         if stdin does not appear to be a terminal; also PYTHONINSPECT=x
-I     : isolate Python from the user&apos;s environment (implies -E and -s)
-m mod : run library module as a script (terminates option list)
-O     : remove assert and __debug__-dependent statements; add .opt-1 before
         .pyc extension; also PYTHONOPTIMIZE=x
-OO    : do -O changes and also discard docstrings; add .opt-2 before
         .pyc extension
-q     : don&apos;t print version and copyright messages on interactive startup
-s     : don&apos;t add user site directory to sys.path; also PYTHONNOUSERSITE
-S     : don&apos;t imply &apos;import site&apos; on initialization
-u     : force the stdout and stderr streams to be unbuffered;
         this option has no effect on stdin; also PYTHONUNBUFFERED=x
-v     : verbose (trace import statements); also PYTHONVERBOSE=x
         can be supplied multiple times to increase verbosity
-V     : print the Python version number and exit (also --version)
         when given twice, print more information about the build
-W arg : warning control; arg is action:message:category:module:lineno
         also PYTHONWARNINGS=arg
-x     : skip first line of source, allowing use of non-Unix forms of #!cmd
-X opt : set implementation-specific option
--check-hash-based-pycs always|default|never:
    control how Python invalidates hash-based .pyc files
file   : program read from script file
-      : program read from stdin (default; interactive mode if a tty)
arg ...: arguments passed to program in sys.argv[1:]

Other environment variables:
PYTHONSTARTUP: file executed on interactive startup (no default)
PYTHONPATH   : &apos;;&apos;-separated list of directories prefixed to the
               default module search path.  The result is sys.path.
PYTHONHOME   : alternate &lt;prefix&gt; directory (or &lt;prefix&gt;;&lt;exec_prefix&gt;).
               The default module search path uses &lt;prefix&gt;\python{major}{minor}.
PYTHONCASEOK : ignore case in &apos;import&apos; statements (Windows).
PYTHONUTF8: if set to 1, enable the UTF-8 mode.
PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.
PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.
PYTHONHASHSEED: if this variable is set to &apos;random&apos;, a random value is used
   to seed the hashes of str and bytes objects.  It can also be set to an
   integer in the range [0,4294967295] to get hash values with a
   predictable seed.
PYTHONMALLOC: set the Python memory allocators and/or install debug hooks
   on Python memory allocators. Use PYTHONMALLOC=debug to install debug
   hooks.
PYTHONCOERCECLOCALE: if this variable is set to 0, it disables the locale
   coercion behavior. Use PYTHONCOERCECLOCALE=warn to request display of
   locale coercion and locale compatibility warnings on stderr.
PYTHONBREAKPOINT: if this variable is set to 0, it disables the default
   debugger. It can be set to the callable of your debugger of choice.
PYTHONDEVMODE: enable the development mode.
PYTHONPYCACHEPREFIX: root directory for bytecode cache (pyc) files. 
</code></pre><footer class="page-footer"><span class="copyright">&#xA9;&#x738B;&#x98DE;&#x7FD4; all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2020-01-21 13:38:01
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="第0章.html" class="navigation navigation-prev " aria-label="Previous page: 第0章、简介和环境搭建">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="第2章.html" class="navigation navigation-next " aria-label="Next page: 第2章、基本数据类型">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"第1章、基础语法","level":"1.4.2","depth":2,"next":{"title":"第2章、基本数据类型","level":"1.4.3","depth":2,"path":"python/第2章.md","ref":"python/第2章.md","articles":[]},"previous":{"title":"第0章、简介和环境搭建","level":"1.4.1","depth":2,"path":"python/第0章.md","ref":"python/第0章.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","expandable-chapters-small","anchors","github","github-buttons","donate","sharing-plus","anchor-navigation-ex","favicon","ad","tbfed-pagefooter","expandable-chapters","back-to-top-button","livereload"],"styles":{"website":"./styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"&copy;王飞翔","modify_label":"修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"ad":{"contentBottom":"","contentTop":""},"github":{"url":"https://github.com/Blankj"},"livereload":{},"splitter":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"./source/images/alipay.jpg","alipayText":"支付宝捐赠","button":"打赏","title":"","wechat":"./source/images/wechatpay.png","wechatText":"微信捐赠"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"favicon":{"shortcut":"./source/images/favicon.jpg","bookmark":"./source/images/favicon.jpg","appleTouch":"./source/images/apple-touch-icon.jpg","appleTouchMore":{"120x120":"./source/images/apple-touch-icon.jpg","180x180":"./source/images/apple-touch-icon.jpg"}},"back-to-top-button":{},"github-buttons":{"buttons":[{"user":"Blankj","repo":"glory","type":"star","size":"small","count":true}]},"expandable-chapters-small":{},"sharing":{"qq":false,"all":["google","facebook","weibo","twitter","qq","qzone","linkedin","pocket"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"expandable-chapters":{}},"theme":"default","author":"王飞翔","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"王某人的学习笔记","language":"zh-hans","links":{"sidebar":{"作者介绍":"https://www.baidu.com"}},"gitbook":"3.2.3","description":"学无止境"},"file":{"path":"python/第1章.md","mtime":"2020-01-21T05:38:01.268Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-01-21T01:17:00.792Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-ad/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

